﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;
using RoadTeam.SysInterface;

namespace RoadTeam.BLL
{
    public class CsAppealBLL : BllBase
    {
        public DataTable GetEmptyTable()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new CsAppeal() { AppealIdentities = "-1" };
            return CsAppeal.Select(where, GlobalConfig.ConnectionString);
        }

        public bool Insert(DataTable dt, string Json)
        {
            base.InserLog(Json);
            //更新对接的乐天系统
            DataTable dt_Appeal = FactoryClass.CreateCsAppeal().GetEmptyTable();
            DataRow dr_Appeal;
            foreach (DataRow dr in dt.Rows)
            {
                dr_Appeal = dt_Appeal.NewRow();
                dr_Appeal[0] = dr["AppealCode"];
                dr_Appeal[1] = dr["AppealDate"];
                dr_Appeal[2] = dr["AppealType"];
                dr_Appeal[3] = dr["AppealContent"];
                dr_Appeal[4] = dr["AppealContact"];
                dr_Appeal[5] = dr["AppealContactPhone"];
                dr_Appeal[6] = dr["AppealAddress"];
                dr_Appeal[7] = dr["AppealCreater"];
                dr_Appeal[8] = dr["AppealRemark"];
                dr_Appeal[9] = dr["AppealIdentities"];
                dt_Appeal.Rows.Add(dr_Appeal);
            }
            FactoryClass.CreateCsAppeal().InsertCsAppeal(dt_Appeal);

            CsAppeal.InsertDatatable(dt, GlobalConfig.ConnectionString);
            return false;
        }
    }
}
